package cn.listener;

import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;

public class BlockEventListener implements Listener {

    @EventHandler
    public void blockBreakEvent(BlockBreakEvent event) {
        Player eventPlayer = event.getPlayer();
        if (!eventPlayer.isOp()) {
            if (eventPlayer.getWorld().getName().equals("world")) {
                event.setCancelled(true);
                eventPlayer.sendMessage("§c这是主城! 你怎么敢的啊?");
            }
        }
    }

    @EventHandler
    public void blockPlaceEvent(BlockPlaceEvent event) {
        Player eventPlayer = event.getPlayer();
        if (!eventPlayer.isOp()) {
            if (eventPlayer.getWorld().getName().equals("world")) {
                event.setCancelled(true);
                eventPlayer.sendMessage("§c这是主城! 你怎么敢的啊?");
            }
        }
    }

}
